import { defineStore } from "pinia";
import { reactive, ref } from "vue";
const useSourceStore = defineStore(
  "source",
  () => {
    const baseUrl = ref("http://101.35.249.138/back");
    const activeBooks = reactive({});
    const source = reactive([
      {
        title: "起点中文网",
        url: "/book/classifies/",
        query: "起点中文网",
        content: [],
      },
    ]);
    const setSource = (data: { index: unknown; content: unknown[] }) => {
      const { index, content } = data;
      source[index].content = content;
    };
    const setActiveBooks = (data: any) => {
      activeBooks.value = data;
    };
    return {
      source,
      setSource,
      baseUrl,
      activeBooks,
      setActiveBooks,
    };
  },
  {
    persist: true,
  },
);

export default useSourceStore;
